package com.guijq.codesegment.springbean;

import com.guijq.codesegment.springbean.config.AppConfig;
import com.guijq.codesegment.springbean.dao.UserDao;
import com.guijq.codesegment.springbean.service.UserService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;

/**
 * @author yangjf
 * @version 0.1.0
 * @time 2018/12/25/025
 */

@ComponentScan("com.guijq.codesegment.springbean")
public class SpringBeanTest {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext annotationConfigApplicationContext =
                new AnnotationConfigApplicationContext(AppConfig.class);

        UserService service = (UserService) annotationConfigApplicationContext.getBean(UserService.class);
        service.test();
        UserDao userDao = (UserDao) annotationConfigApplicationContext.getBean("userDao");
        userDao.query(1);
        System.out.println("test");

    }
}
